package com.jk.controller;

import com.jk.bo.ReserveBO;
import com.jk.po.DestinationPO;
import com.jk.service.ScenicService;
import com.jk.vo.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("scenic")
@Api("景点详情")
public class ScenicController {
    //日志记录对象
    private static Logger logger = LoggerFactory.getLogger(TestController.class);

    @Autowired
    private ScenicService scenicService;
/*
 * @param id
 * @author 赵磊荣
 * @date 2021/7/1 9:35
 * @return 景点详情
 */
    @GetMapping("queryScenicbyId/{id}")
    @ApiOperation(value = "景点详情",produces ="id")
    public@ResponseBody DestinationPO queryScenicbyId(String id){
        DestinationPO destinationPO = new DestinationPO();
        try{
            destinationPO=scenicService.queryScenicbyId(id);
            logger.info("景点详情成功");
        }catch (Exception e){
            logger.error("景点详情失败");
        }
        return destinationPO;
    }

/*
 * @param rbO
 * @author 赵磊荣
 * @date 2021/7/1 9:55
 * @return 下订单(新增到订单表)
 */
    @PostMapping("saveScenicinfo")
    @ApiOperation(value = "新增订单信息")
    public ResultInfo saveScenicinfo(@RequestBody ReserveBO rbO){
        ResultInfo resultInfo = new ResultInfo();
        try{
            scenicService.saveScenicinfo(rbO);
            logger.info("下单成功(未支付)");
            resultInfo.setCode(200);
            resultInfo.setMessage("下单成功(未支付)");
        }catch (Exception e){
            logger.error("下单失败"+e.getMessage());
            resultInfo.setCode(500);
            resultInfo.setMessage("下单失败");
        }
        return resultInfo;
    }




}
